﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace qf_cms
{
	public partial class Site : System.Web.UI.MasterPage
	{
		LogicLayer mgr = new LogicLayer();

		protected string cid = "";
		protected string curBannerImg = "";

		protected void Page_Load(object sender, EventArgs e)
		{
			if (!string.IsNullOrEmpty(Request.QueryString["cid"]))
			{
				cid = Request.QueryString["cid"] + "";
			}
			else if (!string.IsNullOrEmpty(Request.QueryString["pid"]))
			{
				List<CMS_Columns> colList = mgr.ListColumns(Request.QueryString["pid"]);
				if (colList != null && colList.Count > 0)
					cid = colList[0].ColumnID;
			}

			if (!string.IsNullOrEmpty(cid))
				curBannerImg = mgr.GetBannerImgPath(cid, "");
			else if (!string.IsNullOrEmpty(Request.QueryString["aid"]))
				curBannerImg = mgr.GetBannerImgPath("", Request.QueryString["aid"]);

			if (string.IsNullOrEmpty(curBannerImg))
				curBannerImg = "/img/bn_home.jpg";
		}

		protected void WriteTopNav()
		{
			/**<li><a href="#" class="on">首页</a></li>
			<li><a href="#">公司业务</a></li>
			<li><a href="#">公司资质</a></li>
			<li><a href="#">合作伙伴</a></li>
			<li><a href="#">成功案例</a></li>
			<li><a href="#">招贤纳士</a></li>
			<li><a href="#">关于智远</a></li>*/

			List<CMS_Columns> colList = mgr.ListColumns("");
			if (colList != null)
			{
				string url = "";
				foreach (CMS_Columns col in colList)
				{
					url = mgr.GetTopNavMenuUrl(col.ColumnID);
					Response.Write("<li><a href=\"" + url + "\" ");
					
					if(cid == col.ColumnID)
						Response.Write("class=\"on\"");
					Response.Write(" >" + col.ColumnName + "</a></li>");
				}
			}
			
		}
	}
}